
import { build, defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import path, { dirname } from "path";
import { fileURLToPath } from 'url'

let __dirname = fileURLToPath(dirname(import.meta.url))

async function startBuild() {
    await build(defineConfig({
        configFile: false,
        publicDir: false,
        plugins: [vue()],
        resolve: {
            // 配置路径别名
            alias: {
                "@": path.join(__dirname, "./src"),
            },
        },
        base: "/",
        build: {
            externals: ['vue', 'vue-router'],
            output: {
                chunkFileNames: "js/[name].js", // 引入文件名的名称
                entryFileNames: "js/[name].js", // 包的入口文件名称
                globals: {
                    vue: 'Vue'
                }
            },
            lib: {
                entry: path.join(__dirname, 'src/views/index.js'),
                name: 'll-lowcode',
                fileName: 'll-lowcode',
                formats: ['es', 'umd']
            },
            outDir: path.join(__dirname, 'lib')
        }
    }))
}

startBuild()